class Solution(object):
    def subarrayBitwiseORs(self, arr):
        now = set()
        a_set = set()
        for value in arr:
            next_set = set()
            for node in now:
                next_value = node | value
                next_set.add(next_value)
                a_set.add(next_value)
            next_set.add(value)
            a_set.add(value)
            now = next_set
        return len(a_set)



data = Solution()
arr = [1, 2, 4]
print(data.subarrayBitwiseORs(arr))